import React, { Component } from 'react'
import TodoHeader from './TodoHeader'
import List from './List'
export default class Todo extends Component {
  state={
    val:'hah',
    list:[
      {
        msg:'今天',
        isf:true
      },
      {
        msg:'明天',
        isf:true
      },
      {
        msg:'后天',
        isf:true
      }
    ]
  }
  render() {
    return (
      <div>
        <TodoHeader value={this.state.val} fn={this.change} push={this.push}/>
        <List data={this.state.list}/>
      </div>
    )
  }
  change=(data)=>{
    this.setState({
      val:data
    })
  }
  push=()=>{
    const list=this.state.list
    list.push({
      msg:this.state.val,
      isf:false
    })
    this.setState({
      list
    })
  }
}
